import request from '../../api/request'

const state = {
    items: []
}

const getters = {
    all: state => state.items
}

const actions = {
    getItems({commit}){
        // setTimeout(()=>{
        //     commit('setItems', []);
        // },1000)
        request.getMapItems({
            success: (data) => {
                commit('setItems', data.rows);
            },
            error: () => {
                commit('setItems', []);
            }
        });
    }
}

const mutations = {
    setItems(state, items) {
        console.log('setItems', items)
        state.items = items;
    }
}

export default {
    state,
    getters, 
    actions,
    mutations
}